package com.qianfeng.shoon.pet.ui;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;

import com.qianfeng.shoon.pet.R;
import com.qianfeng.shoon.pet.utils.Utils;


/**
 * Created by Shoon on 2015/9/23.
 */
public class SpalshActivity extends BaseActivity {
    private ImageView iv_spalsh;

   private Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what) {
                //第一次运行跳转功能介绍功能界面
                case 1:
                    startMainActivity();
                    break;
                //表示跳转主界面
                case 2:
                    startMainActivity();
//                    staetWelcomeActivity();
                    break;
            }
        }
    };

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_spalsh);

        iv_spalsh = (ImageView) findViewById(R.id.iv_spalsh);
        iv_spalsh.setScaleType(ScaleType.CENTER_CROP);

        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                Message msg = handler.obtainMessage();
                if (Utils.isFirst(SpalshActivity.this)) {
                    msg.what = 1;
                } else {
                    msg.what = 2;
                }
                handler.sendMessage(msg);
            }
        }, 1 * 1000);
    }

//    public void staetWelcomeActivity(){
//        Intent intent = new Intent(getApplicationContext(),WelcomeActivity.class);
//        startActivity(intent);
//    }
    public void startMainActivity(){
        Intent intent = new Intent(getApplicationContext(),MainActivity_.class);
        startActivity(intent);
    }


}
